// common/api.js
import request from './request'

export default {
  // 用户相关
  login(data) {
    return request.post('/user/login', data)
  },
  logout() {
    return request.post('/user/logout')
  },
  getUserInfo() {
    return request.get('/user/info')
  },
  
  // 题目相关
  getProblemList(params) {
    return request.get('/problem/list', { params })
  },
  getProblemDetail(id) {
    return request.get(`/problem/${id}`)
  },
  checkCollection(problemId) {
    return request.get(`/collection/check`, { params: { problem_id: problemId } })
  },
  toggleCollection(problemId, collected) {
    return request.post('/collection/toggle', { problem_id: problemId, collected })
  },
  submitSolution(data) {
    return request.post('/problem/submit', data)
  },
  
  // 错题本
  getWrongProblems(params) {
    return request.get('/wrong/list', { params })
  },
  
  // 刷题记录
  getHistory(params) {
    return request.get('/history/list', { params })
  }
}